using UnityEngine;
using System.Collections;

public class PlayerActivateSwitchState : State<PlayerControl>
{
    #region Singleton

    private static PlayerActivateSwitchState instance = new PlayerActivateSwitchState();
    public static PlayerActivateSwitchState Instance { get { return instance; } }
    private PlayerActivateSwitchState() { }

    #endregion
    
    #region State

    public override void OnEnter(PlayerControl behaviour)
    {
        // TODO
        // Play animation walkAnim
        // Play sound walkSound
        Debug.Log("ACTIVATE");
        behaviour.doActionOnTargetPosition = false;
        //behaviour.PlayAnimation(AnimationConstants.PLAYER_ACTIVATE);
        behaviour.switchControl.Execute(behaviour);
    }

    public override void OnUpdate(PlayerControl behaviour)
    {
        behaviour.transform.rotation = Quaternion.Slerp(behaviour.transform.rotation,
                                                        Quaternion.LookRotation(-behaviour.switchControl.transform.forward),
                                                        0.1f);
        behaviour.Controller.updateRotation = true;
    }

    public override void OnExit(PlayerControl behaviour)
    {
        // TODO
        // Stop animation walkAnim
        // Stop sound walkSound
    }

    public override void OnAction(string name, PlayerControl behaviour, object value)
    {

    }

    #endregion
}
